<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="JavaBean.*,Dao.*,java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>

<body>

<%!   int totalPage; //总页数
     final int pageSize = 3;//每页显示的数量
    
 %>


	<table cellpadding="0" width="300px">
		<thead>
			<tr>
				<th>用户ID</th>
				<th>用户名</th>
				<th>备注</th>
			</tr>
		</thead>
		<tbody>
<%
   
   //获取用户想要显示的页数：
     int pageNo=1;  //显示的页数
     String integer=request.getParameter("pageNo");
     System.out.print(integer);
	 out.print(integer);
     if(integer==null){
    	  integer="1";
     	 pageNo=Integer.parseInt(integer);
     	
      }
     if(pageNo<=1){
    	 pageNo=1;
     }
     if(pageNo > totalPage) {
			pageNo = totalPage;
		}
		   
      PageBean pages=new PageBean();
      System.out.print(pageNo);
 	 out.print(pageNo);
		  
        int startPos = (pageNo-1) * pageSize; //每页开始的帖子
        UserDao  dao=new UserDao();	
        ArrayList<UserBean> users=new ArrayList<UserBean>();
		users=dao.SelectUserInfo();
		int allRecord=users.size();
		pages.setRecord(allRecord);
		pages.setPageRecord(pageSize);
		totalPage=pages.getPageSum();
		for(int i=pageNo*pageSize;i<pageNo*pageSize+3;i++){%>
			
			<tr>
			    <td><%=users.get(i).getUserId() %></td>
				<td><%=users.get(i).getUsername() %></td>
				<td><%=users.get(i).getMark() %></td>	
				<td><a href="DeleteUser.jsp?UserId=<%=users.get(i).getUserId()%>">删除</a></td>	
				<td><a href="EditUser.jsp?UserId=<%=users.get(i).getUserId()%>">编辑</a></td>	
				<td><a href="AddUser.jsp">增加</a></td>	
			<tr>
		<% }
				
	     %>
	   
	    		</tbody>
		 
	</table>
	 总共<%=allRecord %>条记录，当前<%=pageNo%>/<%=totalPage%>页，每页<%=pageSize%>条;
	    <a href=UserList.jsp?pageNo=1>首页</a>
	    <a href=UserList.jsp?pageNo=<%=pageNo-1 %>>上一页</a>
	    <a href=UserList.jsp?pageNo=<%=pageNo+1 %>>下一页</a>
	    <a href=UserList.jsp?pageNo=<%=totalPage%>>末页</a>	
</body>
</html>